<head>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
    <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/script/datecheck.js"></script>
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/script/includedialog.js"></script>
    <script type="text/javascript">
        function jumpAction(submitAction) {
            $("#Msg_effectiveDate").hide();
            $("#Msg_publishText").hide();
            $("#Msg_incorrectDate").hide();
            if (checkIsValidDate($("#effectiveDate").val()) ==false){
                $("#Msg_incorrectDate").show();
                $("#effectiveDate").focus();
                return false;
            }else{
                $("#Msg_incorrectDate").hide();
            }
            $.post('checkpublish.html',{
                id:${dialog.questionnaireId},
                effectiveDate:$("#effectiveDate").val(),
                publishText:$("#publishText").val()
            },
            function(returndata) {
                if (returndata != ""){
                    if (returndata.indexOf("id=OverlappingData")>0){
                        $("#qresults").html(returndata);
                        $("#include").show();
                        return false;
                    }else{
                        var returnStr = returndata.split(";");
                        for (i=0;i<returnStr.length-1;i++){
                            $("#"+returnStr[i]).show();
                        }
                        return false;
                    }
                }else{                	
                    afterSubmitRedirect("dialog", "publish.html", submitAction, "submitAction");
                }
            });
        }
        var closeWindow = function() {
            $('#include').hide();
        }
        function qitemHover(item) {
            $("div.data_tbody div").removeClass("hover");
            $(item).addClass("hover");
        }

        function qitemClick(item, id) {
            $("div.data_tbody div").removeClass("active");
            $(item).addClass("active");
            qId = id;
        }

        function qitemMouseOut(item) {
            $(item).removeClass("hover");
        }
        var navToPublish = function() {
            $("#page").hide();
            $("#publish").show();
            $("div.sub_nav img").each(function() {
                var imgSrc = $(this).attr("src");
                if (imgSrc.indexOf("_off") != -1) {
                    $(this).attr("src", imgSrc.replace("_off", "_on"));
                } else if (imgSrc.indexOf("_on") != -1) {
                    $(this).attr("src", imgSrc.replace("_on", "_off"));
                }
            });
            return false;
        }
        var navToPage = function() {
            $("#page").show();
            $("#publish").hide();
            $("div.sub_nav img").each(function() {
                var imgSrc = $(this).attr("src");
                if (imgSrc.indexOf("_off") != -1) {
                    $(this).attr("src", imgSrc.replace("_off", "_on"));
                } else if (imgSrc.indexOf("_on") != -1) {
                    $(this).attr("src", imgSrc.replace("_on", "_off"));
                }
            });
            return false;
        }
    </script>
</head>
<!-- Menu -->
<jsp:include page="menu.jsp" />

<!--START: Subnav -->
<div class="sub_nav">
    <ul>
        <li>
            <a href="#" onclick="navToPublish();"><img
                    src="<%=request.getContextPath()%>/images/menu/sub_general_on.gif"
                width="114" height="18" alt="publish" /> </a>
        </li>
        <li>
            <a href="#" onclick="navToPage();"><img
                    src="<%=request.getContextPath()%>/images/menu/sub_pages_off.gif"
                width="114" height="18" alt="pages" /> </a>
        </li>
    </ul>
</div>
<!--END: Subnav -->

<!--START: content -->
<div class="content2" id ="publish">
    <div class="insider">
        <div class="corners">
            <div class="corners_top"></div>
            <form id="dialog" method="post">
                <input type="hidden" id="submitAction" name="submitAction" />
                <div class="column1">
                    <div class="col_l">
                        <table width="440" border="0" cellspacing="4"
                               class="formlayout_table">
                            <tr>
                                <th width="188">
                                    <label>
                                        ID:
                                    </label>
                                </th>
                                <td width="240">
                                    ${dialog.refId}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Version:
                                    </label>
                                </th>
                                <td>
                                    ${dialog.version}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Name:
                                    </label>
                                </th>
                                <td>
                                    ${dialog.name}
                                </td>
                            </tr>
                             <tr>
                                <th>
                                    <label>
                                        Vocabulary Name:
                                    </label>
                                </th>
                                <td>
                                    ${dialog.vocabularyname}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Display Title:
                                    </label>
                                </th>
                                <td>
                                    ${dialog.displayTitle}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Description:
                                    </label>
                                </th>
                                <td>
                                    ${dialog.description}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Function:
                                    </label>
                                </th>
                                <td>${function}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Region:
                                    </label>
                                </th>
                                <td>${region}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Product Line:
                                    </label>
                                </th>
                                <td>${productType}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Locale:
                                    </label>
                                </th>
                                <td>${locale}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Theme:
                                    </label>
                                </th>
                                <td>${theme}
                                </td>
                            </tr>
                            <tr>
					            <th>
					                <label>
					                    Enable Save:
					                </label>
					            </th>
					            <td>
					                <c:if test="${dialog.enableSave}">
					                    Yes
					                </c:if>
					                <c:if test="${not dialog.enableSave}">
					                    No
					                </c:if>
					            </td>
					        </tr>
                            <tr>
                                <th>
                                    <label>
                                        Summary Report:
                                    </label>
                                </th>
                                <td>
                                    <c:if test="${dialog.summaryReport == true}">Yes</c:if>
                                    <c:if test="${dialog.summaryReport == false}">No</c:if>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Decision Service Name:
                                    </label>
                                </th>
                                <td>${dialog.decisionServiceName}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Decision Service Version:
                                    </label>
                                </th>
                                <td>${dialog.decisionServiceVersion}
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        Exit Page Url:
                                    </label>
                                </th>
                                <td>${dialog.exitpageurl}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <table width="283" border="0" cellspacing="4"
                           class="formlayout_table fr">
                        <tr>
                            <th width="159">
                                <label>
                                    Sibling ID:
                                </label>
                            </th>
                            <td width="111">${dialog.sibling.refId}
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    Sibling Version:
                                </label>
                            </th>
                            <td>${dialog.sibling.version}
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    Publication Status:
                                </label>
                            </th>
                            <td>
                                ${dialog.publicationStatus.name}
                            </td>
                        </tr>

                        <tr>
                            <th width="159">
                                <label>
                                    Last Modified Date:
                                </label>
                            </th>
                            <td width="111"><fmt:formatDate value="${dialog.modifiedOn}" pattern="dd-MMM-yyyy" /></td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    Last Modified By:
                                </label>
                            </th>
                            <td>${dialog.modifiedBy.username}</td>
                        </tr>

                        <tr>
                            <th>
                                <label>
                                    Published Date:
                                </label>
                            </th>
                            <td></td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    Published By:
                                </label>
                            </th>
                            <td></td>
                        </tr><tr>
                            <th>
                                <label>
                                    Effective Date:
                                </label>
                            </th>
                            <td>
                                <input name="effectiveDate" id="effectiveDate" type="text" style="width:110px;padding:1px 3px;" maxlength="255"/>
                            </td>
                        </tr><tr>
                            <th>
                                <label>
                                    End Date:
                                </label>
                            </th>
                            <td></td>
                        </tr><tr>
                            <th>
                                <label>
                                    Publish Notes:
                                </label>
                            </th>
                            <td>
                                <textarea name="publishText" id="publishText" style="width:110px;height:3em;padding:1px 3px;" onkeypress="if(this.value.length >=255) return false;" onpaste="if(this.value.length >=255) return false;"></textarea>
                            </td>
                        </tr>

                        <tr>
                            <th>
                                <label>
                                    Retired By:
                                </label>
                            </th>
                            <td>
                                ${dialog.retiredBy.username}
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    Retire Date:
                                </label>
                            </th>
                            <td><fmt:formatDate value="${dialog.retiredOn}" pattern="dd-MMM-yyyy" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    Retire Notes:
                                </label>
                            </th>
                            <td>
                                ${dialog.retiredNote}
                            </td>
                        </tr>
                    </table>
                </div>
                <ul class="functions1">
                    <li>
                        <a href="#" onclick="jumpAction('SUBMIT');"><img
                                src="<%=request.getContextPath()%>/images/btn/functions1/btn_save.gif"
                            width="122" height="23" class="btn" /> </a>
                    </li>
                    <li>
                        <a href="#" onclick="jumpAction('SUBMIT_AND_EXIT');"><img
                                src="<%=request.getContextPath()%>/images/btn/functions1/btn_save_exit.gif"
                            width="122" height="23" class="btn" /> </a>
                    </li>
                    <li>
                        <a href="list.html?from=cancel&checkSearch=list"><img
                                src="<%=request.getContextPath()%>/images/btn/functions1/btn_cancel.gif"
                            alt="" width="122" height="23" class="btn" /> </a>
                    </li>
                </ul>
                <div class="corners_bottom"></div>
            </form>
            <div id="include" style="display:none;position:absolute;top:100px">
                <!-- POPUP BEGIN -->
                <div class="popup">
                    <div class="popup_top">
                        <span>
                            <input type="image" src="<%=request.getContextPath()%>/images/icon/close.gif" class="close" width="16" height="16" alt="close" onclick="closeWindow();"/>
                        </span>
                    </div>
                    <div class="popup_insider">
                        <div class="tips">
                            <p>Publication of this Dialog failed.The following active Dialogs fall within this Dialog's date range and share identical context attributes.This problem can be corrected by modifying this Dialog's context attributes or retiring the follwing Dialogs.</p>
                            <a href="#"><img src="<%=request.getContextPath()%>/images/btn/btn_ok.gif" width="68" height="23" alt="ok" class="btn" onclick="closeWindow();" /></a>
                        </div>

                        <table width="100%" cellspacing="0" class="data_thead">
                            <thead>
                                <tr>
                                    <th width="8%">id</th>
                                    <th width="7%">Version</th>
                                    <th width="17%">Display Title</th>
                                    <th width="9%">Label</th>
                                    <th width="8%">Function</th>
                                    <th width="7%">Region </th>
                                    <th width="10%">Product</th>
                                    <th width="10%">Locale</th>
                                    <th width="12%">Eff Date </th>
                                    <th width="12%" class="end">End Date</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>

                        <div class="scrollbar">
                            <div id="qresults" class="data_tbody brief">
                            </div>
                        </div>
                    </div>
                    <div class="popup_bottom"><span></span></div>
                </div>
                <!--END: popup -->
            </div>

        </div>
        <div class="message">
            ${message}<br>
            <style> p { margin:0px }</style>
            <font color="red">
                <p id="Msg_effectiveDate" style="display:none;">${Msg_effectiveDate}</p>
                <p id="Msg_publishText" style="display:none;">${Msg_publishText}</p>
                <p id="Msg_incorrectDate" style="display:none;">${Msg_incorrectDate}</p>
                <p id="Msg_publishTextLen" style="display:none;">${Msg_publishTextLen}</p>
                <p id="Msg_noServiceName" style="display:none;">${Msg_noServiceName}</p>
            </font>
        </div>
    </div>
</div>
<!--END: content -->
<!--START: conent -->
<div class="content2" id="page" style="display:none">
    <div class="insider">
        <div class="corners">
            <div class="corners_top"></div>

            <jsp:include page="baseInfo.jsp" />

            <ul class="functions1 fun1_3">
                <a href="list.html?checkSearch=list">
                    <img class="btn" src="<%= request.getContextPath()%>/images/btn/functions1/back_to_results.gif"/>
                </a>

            </ul>
            <div class="corners_bottom"></div>
        </div>

        <div class="error">
            <h3 id="pagemessage">
                ${pagemessage}
            </h3>
        </div>

        <ul class="functions2">
            <li class="view">
                <a href="#" onclick="linkAction('../questionset/view',true)">
                    <img name="qbtn" class="btn" src="<%= request.getContextPath()%>/images/btn/functions2/btn_view_light.gif" alt="view" />
                </a>
            </li>

        </ul>

        <div class="question_sets">
            <div class="question_sets_inside">
                <form id="includePages" name="includePages" method="post">
                    <input type="hidden" name="id" value="${param.id}" />
                    <input type="hidden" id="submitAction2" name="submitAction" />

                    <div class="question">

                        <jsp:include page="includepage.jsp" />

                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--START: Footer -->
<div class="footer"></div>
<!--END: Footer -->